@extends('welcome')

@section('titletitle','订单提交--优品惠')
@section('zhong_content')
<style type="text/css">
	.aa{background:#E9E9E9;}
	.xx{position:absolute;}
</style>
<form action="{{url('/home/address/insert')}}" method="post">
   <div class="row">
   	  <div class="col-md-2"></div> 
   	  <div class="col-md-8">
   	  	<div class="row">
	   	  <div class="col-md-2" style="font-size:16px;">确认订单信息</div> 
	   	  <div class="col-md-2"></div> 
	   	  <div class="col-md-2"></div> 
	    </div>
   	  </div> 
   	  <div class="col-md-2"></div> 
   </div>
   <div class="row">
   	  <div class="col-md-2"></div> 
   	  <div class="col-md-8">
   	  	<div class="row">
	   	  <div class="col-md-2" style="font-size:16px;color:red">
	     @if(session('success'))
			{{session('success')}}
		 @endif
	   	  </div> 
	   	  <div class="col-md-2"></div> 
	   	  <div class="col-md-2"></div> 
	    </div>
   	  </div> 
   	  <div class="col-md-2"></div> 
   </div>
  
   <div class="row">
   	  <div class="col-md-2"></div> 
   <!-- 选择收货地址 -->
   	  <div class="col-md-8" style="margin-bottom:5px;border:1px #E9E9E9 solid">
   	  	<div class="row" style="margin-bottom:10px;height:30px">
	   	  <!-- 头部 -->
	   	  <div class="col-md-12" style="font-size:16px;margin-top:10px;">
   	  			<div class="col-md-2"><span style="color:red;width:3px;">|</span>&nbsp;选择收货地址</div> 
	   	  </div>
	   	  <!-- 收货地址 -->
	   	  <div class="col-md-12">
	   	  		<!-- 收货人 设置栏 -->
	   	  @foreach($dingdan_tijiao as $kk=>$vv)

				<div @if($vv->statuss == 1) class="col-md-5 dizhi addresses" @else class="col-md-5 dizhi addresses aa" @endif style="height:150px;margin-top:20px;border:1px #E9E9E9 solid;margin-right:15px;" >
	   	  			<div class="col-md-12" style="margin-top:10px;">
						<div class="col-md-5" style="font-weight:bold">{{$vv->dizhi_name}} 收</div> 
						
   	  			<input type="hidden" name="dizhi_id" aid="{{$vv->id}}">
						<div class="col-md-7">设置 <a class="delete" style="cursor:pointer">删除</a> <a class="default" style="cursor:pointer">@if($vv->statuss == 1) 设为默认 @else 默认地址 @endif</a></div> 	  				
	   	  			</div> 
	   	  			<!-- 收货地址 -->
					<div class="col-md-12 add" add="{{$vv->sheng}},{{$vv->shi}},{{$vv->xian}}" style="margin-top:10px;"></div><span>{{$vv->content}}</span> 
	   	  			<!-- 手机号 -->
	   	  			<div class="col-md-10" style="margin-top:40px;">手机号:{{$vv->phone}}</div> 
	   	  			<div class="col-md-2 default-dui" style="display:none;margin-top:40px;color:#336633;border:1px solid #E9E9E9;border-radius:50%;height:30px;line-height:30px;">√</div> 

   	  			</div>	

	   	  @endforeach
	   	  </div>
	   	  <div class="col-md-12" style="margin-bottom:15px;">
	  			<!-- 添加新地址 -->
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="myModalLabel">添加新地址</h4>
      
      </div>
      
      
      <div class="modal-body">
	      <div class="form-group">
		    <label for="name">收货人</label>
		    <input type="text" class="form-control" placeholder="真实姓名" name="dizhi_name" style="width:540px;">
		  </div>
		  <div class="form-group">
		    <label for="name">联系电话</label>
		    <input type="text" class="form-control" placeholder="手机号" name="phone" style="width:540px;">
		  </div>
		  <!-- 三级联动 -->
            <!--导入插件-->
          <div class="form-group">
            <script type="text/javascript" src="/Home/list/sanjiliandong/jquery.js"></script>
            <script type="text/javascript" src="/Home/list/sanjiliandong/area.js"></script>
            <script type="text/javascript" src="/Home/list/sanjiliandong/location.js"></script>
			
			<label for="name">地址</label>
	      	<!--层级联动选择框-->
	      	<div>
            <select id="loc_province" class="" name="sheng" style="width:80px;height:30px;border:1px solid #CCCCCC;border-radius:3px;"></select>
            <select id="loc_city" class="" name="shi" style="width:100px;height:30px;border:1px solid #CCCCCC;border-radius:3px;"></select>
            <select id="loc_town" class="" name="xian" style="width:120px;height:30px;border:1px solid #CCCCCC;border-radius:3px;"></select>
            <!-- 三级联动 end-->
            </div>
          </div>

          <script type="text/javascript">
          		$(document).ready(function() {
					showLocation();
					//获取省市县信息并设置
					$('.addresses .add').each(function(){
						var str = $(this).attr('add');
						var info = getInfo(str);
						// console.log(str);
						$(this).html(info);
					});
						// alert(str);

					//定义获取城市信息方法
					function getInfo(str){
						//console.log(str);
						//拆分字符串
						var arr = str.split(',');
						// console.log(arr);	
						var ls  = new Location;
						var l = ls.items;
						// console.log(l['0,1,2']['5']);
						var sheng = l['0'][arr[0]];
						var shi = l['0,'+arr[0]][arr[1]];
						var xian = l['0,'+arr[0]+','+arr[1]][arr[2]];
						return sheng+shi+xian;
					}			
				});	


				//绑定默认地址
				$('.default').click(function(){
				    var dd = $(this);
					dd.parents('.dizhi').addClass('aa');
					dd.parents('.dizhi').siblings().removeClass('aa');
					// alert(222);
					var id = $(this).parents('.dizhi').find('input[name=dizhi_id]').attr('aid');
					// alert(id);
					// $('input[name=dizhi_id]').val(id);
					$.ajaxSetup({
				          headers: {
				              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
				          }
				    });
					$.get("{{url('/home/address/update')}}",{did:id},function(data){
						console.log(data);
						if(data == 1){
							alert('设置成功');
							$('.default').html('设为默认')
							dd.html('默认地址');
						}
						if(data == 2){
							alert('设置失败');
						}
						if(data == 3){
							alert('该地址已经是默认地址');
						}
					});
				});

				//绑定删除地址
				$('.delete').click(function(){
				    var dd = $(this);
					// alert(222);
					var id = $(this).parents('.dizhi').find('input[name=dizhi_id]').attr('aid');
					// alert(id);
					// $('input[name=dizhi_id]').val(id);
					$.ajaxSetup({
				          headers: {
				              'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
				          }
				    });
					$.get("{{url('/home/address/delete')}}",{did:id},function(data){
						console.log(data);
						if(data == 1){
							alert('删除成功');
							dd.parents('.dizhi').hide();
						}else{
							alert('删除失败');
						}
					});
				});	
				
		   </script>

		  <div class="form-group">
		    <label for="name">详细地址</label>
		    <input type="text" class="form-control" placeholder="详细地址" name="content" style="width:540px;">
		  </div>

      </div>
      <div class="modal-footer">
		{{ csrf_field() }}   	  
        <button class="btn btn-primary">添加</button>
        <button type="button" class="btn btn-default" data-dismiss="modal">退出</button>
      </div>
    </div>
  </div>
</div>
	  <div><button  style="margin-top:10px;height:40px;line-height:30px;" type="button" class="btn btn-primary btn-lg col-md-2 " data-toggle="modal" data-target="#myModal">添加新地址</button>
</div> 
	   	  	
	   	  </div>
	    </div>
   	  </div> 
   	  <div class="col-md-2"></div> 
   </div>
</form>  
   	<!-- 选择收货地址 end-->
   	<!-- 选择支付方式 -->
</div>
<form action="{{url('/home/order/tijiao')}}" class="form" method="post">   

   	<!-- 讯则支付方式 end -->
   <div class="row">
   	  <div class="col-md-2"></div>
   	  <div class="col-md-8" style="border:1px solid #E9E9E9;margin-top:20px;">
	   	  <div class="col-md-12" style="margin-top:20px;height:30px;font-size:16px">
	   	  	<div class="col-md-2"><span style="color:red;width:3px;">|</span>&nbsp;选择支付方式</div>	
	   	  </div> 
	   	  <div class="col-md-12" style="margin-top:20px;height:30px;">
	   	  	<div class="col-md-2"><input type="radio" name="payway" value="1" id="zf">在线付款</div>
	   	  	<div class="col-md-4">支持支付宝、财付通、微信、银行卡、网银</div>	
	   	  </div> 
	   	  
	   	  <div class="col-md-12" style="margin-top:20px;height:30px;">
	   	  	<div class="col-md-2"><input type="radio" name="payway" value="2">货到付款</div>
	   	  	<div class="col-md-4">送货上门后再付款。</div>	
	   	  	
	   	  </div> 
   	  	
   	  </div>
   	  <div class="col-md-2"></div>	
   </div>
   <script type="text/javascript">
   $('#zf').click(function(){

   })
   </script>


   <div class="row" style="height:auto;">
   	  <div class="col-md-2"></div> 
   	  <div class="col-md-8" style="border:1px solid #E9E9E9;margin-top:20px;">
	   	  <div class="col-md-12" style="font-size:16px;height:30px">
   	  			<div class="col-md-3"><span style="color:red;width:3px;">|</span>&nbsp;订单商品信息</div> 
	   	  </div> 
   	  @foreach($orders as $k=>$v)
	   	  <div class="col-md-12" style="border:1px solid #E9E9E9;margin-bottom:10px;">
	   	  	<div class="row" style="height:30px;background:#F7F7F7;">
              <div class="col-md-1" style="height:30px;">
                <div style="width:60px;height:22px;color:#FCFCFC ;background:#3399FF;border:1px solid #E9E9E9;text-align:center;line-height:22px;margin-top:5px;">网站订单</div>

              </div>
              <div class="col-md-3" style="height:30px;">
                <div style="height:22px;text-align:center;line-height:22px;margin-top:5px;">商品：</div>
              </div>     
              <div class="col-md-3" style="height:30px;">
                <div style="height:22px;text-align:center;line-height:22px;margin-top:5px;">单价：</div>
              </div>     
              <div class="col-md-3" style="height:30px;">
                <div style="height:22px;text-align:center;line-height:22px;margin-top:5px;">数量：</div>
              </div> 
              <div class="col-md-1" style="height:30px;">
                <div style="height:22px;text-align:center;line-height:22px;margin-top:5px;">小记：</div>
              </div>
           </div>
	   	  </div> 
   	  		<input type="hidden" name="dingdan_id[]" value="{{$v->dingdan_id}}">
   	  		<input type="hidden" name="dingdan_pic[]" value="{{$v->pic}}">
   	  		<input type="hidden" name="dingdan_name[]" value="{{$v->goods_name}}">
   	  		<input type="hidden" name="dingdan_color[]" value="{{$v->dingdan_color}}">
   	  		<input type="hidden" name="dingdan_size[]" value="{{$v->dingdan_size}}">
   	  		<input type="hidden" name="dingdan_content[]" value="{{$v->content}}">
   	  		<input type="hidden" name="price[]" value="{{$v->price}}">
   	  		<input type="hidden" name="atime[]" value="{{$v->dingdan_time}}">
   	  		<input type="hidden" name="status[]" value="{{$v->status}}">
   	  		<input type="hidden" name="dingdan_num[]" value="{{$v->num}}">
   	  	  <div class="row" style="height:80px;">
              <div class="col-md-1" style="height:80px;">
                <div style="height:80px;"><img style="height:80px;" src="/uploads/{{$v->pic}}" alt=""></div>

              </div>
              <div class="col-md-3" style="height:80px;">
                <div style="height:80px;text-align:center;margin-top:5px;">{{$v->goods_name}}</div>
              </div>     
              <div class="col-md-3" style="height:80px;">
                <div style="height:80px;text-align:center;margin-top:5px;">{{$v->price}}</div>
              </div>     
              <div class="col-md-3" style="height:80px;">
                <div style="height:80px;text-align:center;margin-top:5px;">{{$v->num}}</div>
              </div> 
              <div class="col-md-1" style="height:80px;">
                <div style="height:80px;text-align:center;margin-top:5px;">{{$v->price*$v->num}}</div>
              </div>
           </div>	
   	@endforeach
   	  	  </div>
           <div class="col-md-2"></div> 
   	  	 </div>
   	<div class="row" style="height:auto;">
   	  <div class="col-md-2"></div> 
   	  <div class="col-md-8">
  	    <div class="col-md-12" style="margin-bottom:10px;margin-top:10px;border:1px solid #E9E9E9"></div> 
  	    <div class="col-md-12" style="margin-bottom:10px;background:#E9E9E9;">
	   	  <div class="col-md-3" style="height:30px;line-height:30px;">
				<div class="col-md-6">其他信息:</div>
				<div class="col-md-6"><input type="checkbox"> 发票</div>
			
	   	  </div> 
	   	  <div class="col-md-3"></div> 
	   	  <div class="col-md-3"></div> 
   	 	  <div class="col-md-3">
		   	  <div class="col-md-12" style="height:30px;line-height:30px;">商品金额:{{$zongjia}}元</div> 
		   	  <div class="col-md-12" style="height:30px;line-height:30px;">运费:<span style="color:blue">包邮</span></div> 
		   	  <div class="col-md-12" style="height:30px;line-height:30px;"></div> 
		   	  <div class="col-md-12" style="height:30px;line-height:30px;">实付金额:{{$zongjia}}元</div> 
		   	  <div class="col-md-12" style="height:30px;line-height:30px;"></div> 
		   	  <div class="col-md-12">
		   	  {{ csrf_field() }}
	   	 	  		<div><button class="col-md-8 col-md-offset-3 tijiao" style="border-radius:3px;height:30px;background:#FF504A;border-radius:3px;text-align:center;line-height:30px;">提交订单</button></div>	
		   	  </div> 
   	 	  	
   	 	  </div> 
 </form> 
       	
  	    </div>
   	  </div> 
   	  <div class="col-md-2"></div> 
   </div>
@endsection
@section('myjs')

@endsection